#define BOOKMARKS_FILENAME ".gtk-bookmarks"
+#define HIDDEN_FILENAME ".hidden"
+
#define FOLDER_CACHE_LIFETIME 2 /* seconds */
typedef struct _GtkFileSystemUnixClass GtkFileSystemUnixClass;
guint have_stat : 1;
guint have_mime_type : 1;
guint is_network_dir : 1;
+ guint have_hidden : 1;
time_t asof;
};
struct stat statbuf;
char *mime_type;
IconType icon_type;
+ gboolean hidden;
};
static const GtkFileInfoType STAT_NEEDED_MASK = (GTK_FILE_INFO_IS_FOLDER |
static gboolean filename_is_root (const char *filename);
+static gboolean file_is_hidden (GtkFileFolderUnix *folder_unix,
+ const char *basename);
+
static gboolean fill_in_names (GtkFileFolderUnix *folder_unix, GError **error);
static void fill_in_stats (GtkFileFolderUnix *folder_unix);
static void fill_in_mime_type (GtkFileFolderUnix *folder_unix);
+static void fill_in_hidden (GtkFileFolderUnix *folder_unix);
static char * get_parent_dir (const char *filename);
folder_unix->stat_info = NULL;
folder_unix->have_mime_type = FALSE;
folder_unix->have_stat = FALSE;
+ folder_unix->have_hidden = FALSE;
}
g_object_ref (folder_unix);
folder_unix->asof = now;
folder_unix->have_mime_type = FALSE;
folder_unix->have_stat = FALSE;
+ folder_unix->have_hidden = FALSE;
if ((system_unix->have_afs &&
system_unix->afs_statbuf.st_dev == statbuf.st_dev &&
/* Creates a new GtkFileInfo from the specified data */
static GtkFileInfo *
-create_file_info (const char *filename,
- const char *basename,
- GtkFileInfoType types,
- struct stat *statbuf,
- const char *mime_type)
+create_file_info (GtkFileFolderUnix *folder_unix,
+ const char *filename,
+ const char *basename,
+ GtkFileInfoType types,
+ struct stat *statbuf,
+ const char *mime_type)
{
GtkFileInfo *info;
if (types & GTK_FILE_INFO_IS_HIDDEN)
{
- if (basename[0] == '.' || basename[strlen (basename) - 1] == '~')
+ if (file_is_hidden (folder_unix, basename))
gtk_file_info_set_is_hidden (info, TRUE);
}
entry = create_stat_info_entry_and_emit_add (folder_unix, filename, basename, &statbuf);
}
- info = create_file_info (filename, basename, types, &entry->statbuf, entry->mime_type);
+ info = create_file_info (folder_unix, filename, basename, types, &entry->statbuf, entry->mime_type);
g_free (basename);
return info;
}
else
mime_type = NULL;
- info = create_file_info (filename, basename, types, &statbuf, mime_type);
+ info = create_file_info (folder_unix, filename, basename, types, &statbuf, mime_type);
g_free (basename);
return info;
}
folder_unix->have_mime_type = TRUE;
}
+static void
+fill_in_hidden (GtkFileFolderUnix *folder_unix)
+{
+ gchar *hidden_file;
+ gchar *contents;
+
+ if (folder_unix->have_hidden)
+ return;
+
+ hidden_file = g_build_filename (folder_unix->filename, HIDDEN_FILENAME, NULL);
+
+ if (g_file_get_contents (hidden_file, &contents, NULL, NULL))
+ {
+ gchar **lines;
+ int i;
+
+ lines = g_strsplit (contents, "\n", -1);
+ for (i = 0; lines[i]; i++)
+ {
+ if (lines[i][0])
+ {
+ struct stat_info_entry *entry;
+
+ entry = g_hash_table_lookup (folder_unix->stat_info, lines[i]);
+ if (entry != NULL)
+ entry->hidden = TRUE;
+ }
+ }
+
+ g_strfreev (lines);
+ g_free (contents);
+ }
+
+ g_free (hidden_file);
+ folder_unix->have_hidden = TRUE;
+}
+
static GtkFilePath *
filename_to_path (const char *filename)
{
return (after_root != NULL && *after_root == '\0');
}
+static gboolean
+file_is_hidden (GtkFileFolderUnix *folder_unix,
+ const char *basename)
+{
+ struct stat_info_entry *entry;
+
+ if (basename[0] == '.' || basename[strlen (basename) - 1] == '~')
+ return TRUE;
+
+ if (folder_unix->have_stat)
+ {
+ fill_in_hidden (folder_unix);
+
+ entry = g_hash_table_lookup (folder_unix->stat_info, basename);
+
+ if (entry)
+ return entry->hidden;
+ }
+
+ return FALSE;
+}
+
#define __GTK_FILE_SYSTEM_UNIX_C__
#include "gtkaliasdef.c"